﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Remind.BLL;
using Remind.Model;

namespace Remind.View
{
    public partial class frmLogin : Form
    {
        ////用户业务类
        //private readonly UserBLL userBLL = new UserBLL();
        ////加载所有用户名
        //IList<UserInfo> users = null;

        ////当前用户
        //public UserInfo user = null;
        public frmLogin()
        {
            InitializeComponent();
        }
        //加载所有用户信息
        private void frmLogin_Load(object sender, EventArgs e)
        {
            ////确定用户表里面有数据，否则初始化系统管理员
            //if (userBLL.GetUserCount()==0)
            //{
            //    UserInfo user = new UserInfo();
            //    user.Uname = "admin";
            //    user.Upwd = "123";
            //    userBLL.InsertUser(user);
            //}
            //users = userBLL.GetUsers(); 
            //foreach (UserInfo item in users)
            //{
            //    //this.cmbUser.Items.Add(item.Uname);
            //    //this.cmbUser.va
            //}
            //this.cmbUser.SelectedIndex = 0;
        }
        //确定
        private void BtnOk_Click(object sender, EventArgs e)
        {
            string pwd = txtPwd.Text.Trim();
            string appwd = System.Configuration.ConfigurationManager.AppSettings["admin"];
            if (FrmPws.Jiami(pwd) == appwd)
            {
                this.DialogResult = DialogResult.OK;
                //this.Close();
            }
            else
            {
                MessageBox.Show("您输入的密码错误，请重新输入！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPwd.Text = "";
                txtPwd.Focus();
            }
           // string uname = this.cmbUser.Text.Trim();
            //string upwd = txtPwd.Text.Trim();
            //user = userBLL.GetUserByUname(uname);
            //if (user == null)
            //    MessageBox.Show("您输入的用户名错误，请重新输入！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //else if (user.Upwd != upwd)
            //    MessageBox.Show("您输入的密码错误，请重新输入！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //else
            //    this.DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
            Application.Exit();
        }

        private void frmLogin_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Application.Exit();
        }

    }
}
